<?php


namespace Tests;


use Tests\Traits\InteractsWithTenancy;

abstract class TenancyTestCase extends TestCase
{
    use CreatesApplication, InteractsWithTenancy;

    protected $tenantUrl;

    public function setUp(): void
    {
        parent::setUp();
        $fqdn = config('app.url');
        $fqdn = mb_ereg_replace('http:\/\/|https:\/\/','', $fqdn);
        $this->tenantUrl = $fqdn;
        $this->setUpTenancy();
        $this->activateTenant();

        $this->duringSetup();

    }

    protected function duringSetup()
    {
        //
    }

    protected function tearDown(): void
    {
        $this->cleanupTenancy();
        parent::tearDown();
    }

    protected function assertTenantExists($fqdn)
    {

        $this->assertDatabaseHas('hostnames', ['fqdn' => $fqdn], env('DB_CONNECTION'));

    }
}
